/*
 * Decompiled with CFR 0.150.
 * 
 * Could not load the following classes:
 *  cn.hutool.core.util.ObjectUtil
 *  com.alibaba.fastjson.JSON
 *  de.felixroske.jfxsupport.FXMLController
 *  javafx.collections.FXCollections
 *  javafx.collections.ObservableList
 *  javafx.fxml.FXML
 *  javafx.fxml.Initializable
 *  javafx.scene.Node
 *  javafx.scene.control.Alert
 *  javafx.scene.control.Alert$AlertType
 *  javafx.scene.control.CheckBox
 *  javafx.scene.control.TableCell
 *  javafx.scene.control.TableColumn
 *  javafx.scene.control.TableView
 *  javafx.scene.control.cell.PropertyValueFactory
 *  javafx.scene.layout.AnchorPane
 *  javafx.util.Callback
 *  org.springframework.beans.factory.annotation.Autowired
 *  org.springframework.util.CollectionUtils
 */
package com.gys.controller.addBox;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.gys.common.business.ClearBoxTipUtil;
import com.gys.common.data.HttpJson;
import com.gys.controller.BaseController;
import com.gys.controller.addBox.AddBoxController;
import com.gys.controller.dataManger.ControllerManger;
import com.gys.data.addBox.AddBoxInfoOutData;
import com.gys.data.addBox.ClearBoxTipOutData;
import de.felixroske.jfxsupport.FXMLController;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.Alert;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import javafx.util.Callback;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;

@FXMLController
public class ClearBoxTipController
extends BaseController
implements Initializable {
    @FXML
    private TableColumn<ClearBoxTipOutData, String> gschDate;
    @FXML
    private TableColumn<ClearBoxTipOutData, String> gsehDate;
    @FXML
    private TableColumn<ClearBoxTipOutData, String> gschVoucherId;
    @FXML
    private TableColumn<ClearBoxTipOutData, String> gschExaVoucherId;
    @FXML
    private TableView<ClearBoxTipOutData> tableView;
    @FXML
    private TableColumn<ClearBoxTipOutData, CheckBox> checkBox;
    @FXML
    private TableColumn<ClearBoxTipOutData, String> gsehType;
    @FXML
    private AnchorPane pane;
    @Autowired
    private AddBoxController addBoxController;
    private ObservableList<ClearBoxTipOutData> observableTableList = FXCollections.observableArrayList(new ArrayList());
    AddBoxInfoOutData addBoxInfoOutData = null;

    public void initialize(URL location, ResourceBundle resources) {
        ControllerManger.controllerMap.put(this.getClass().getSimpleName(), this);
        this.init();
    }

    @Override
    public void init() {
        if (ObjectUtil.isEmpty(this.pane)) {
            return;
        }
        this.addBoxInfoOutData = null;
        this.initTableView();
    }

    private void initTableView() {
        List dataList = new ArrayList();
        HashMap<String, Object> param = new HashMap<String, Object>();
        HttpJson httpJson = ClearBoxTipUtil.selectList(param);
        if (!httpJson.isSuccess()) {
            Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", httpJson.getMsg());
            alert.showAndWait();
            return;
        }
        dataList = JSON.parseArray((String)httpJson.getMsg(), ClearBoxTipOutData.class);
        this.observableTableList.clear();
        if (ObjectUtil.isNotEmpty(dataList)) {
            this.observableTableList = FXCollections.observableArrayList(dataList);
        }
        this.bingTableCell();
        this.tableView.setItems(this.observableTableList);
        this.checkBox.setCellValueFactory(cellData -> ((ClearBoxTipOutData)cellData.getValue()).getCheckBox().getCustomCheckBox());
        this.initCheckBox();
    }

    public void initCheckBox() {
        this.checkBox.setCellFactory(col -> {
            TableCell<ClearBoxTipOutData, CheckBox> cell = new TableCell<ClearBoxTipOutData, CheckBox>(){

                protected void updateItem(CheckBox item, boolean empty) {
                    super.updateItem(item, empty);
                    this.setGraphic((Node)item);
                    if (item != null) {
                        item.setOnMouseClicked(col -> {
                            if (CollectionUtils.isEmpty((Collection)ClearBoxTipController.this.observableTableList)) {
                                return;
                            }
                            int index = this.getIndex();
                            for (int i = 0; i < ClearBoxTipController.this.observableTableList.size(); ++i) {
                                if (i == index) continue;
                                ((ClearBoxTipOutData)ClearBoxTipController.this.observableTableList.get(i)).getCheckBox().setSelectStatus(false);
                            }
                        });
                    }
                }
            };
            return cell;
        });
    }

    private void bingTableCell() {
        this.checkBox.setCellValueFactory((Callback)new PropertyValueFactory(this.checkBox.getId()));
        this.gschVoucherId.setCellValueFactory((Callback)new PropertyValueFactory(this.gschVoucherId.getId()));
        this.gschDate.setCellValueFactory((Callback)new PropertyValueFactory(this.gschDate.getId()));
        this.gschExaVoucherId.setCellValueFactory((Callback)new PropertyValueFactory(this.gschExaVoucherId.getId()));
        this.gsehDate.setCellValueFactory((Callback)new PropertyValueFactory(this.gsehDate.getId()));
        this.gsehType.setCellValueFactory((Callback)new PropertyValueFactory(this.gsehType.getId()));
    }

    @FXML
    private void sureAction() {
        this.observableTableList.forEach(item -> {
            if (item.getCheckBox().isSelected().booleanValue()) {
                HashMap<String, Object> param = new HashMap<String, Object>();
                param.put("gschVoucherId", item.getGschVoucherId());
                HttpJson httpJson = ClearBoxTipUtil.getAddBoxInfo(param);
                if (httpJson.isSuccess()) {
                    this.addBoxInfoOutData = (AddBoxInfoOutData)JSON.parseObject((String)httpJson.getMsg(), AddBoxInfoOutData.class);
                    this.cancelAction();
                    this.addBoxController.addBoxByClear(this.addBoxInfoOutData.getGsihVoucherId());
                } else {
                    Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", httpJson.getMsg());
                    alert.showAndWait();
                }
            }
        });
    }

    @FXML
    private void cancelAction() {
        this.pane.getScene().getWindow().hide();
    }

    public TableColumn<ClearBoxTipOutData, String> getGschDate() {
        return this.gschDate;
    }

    public TableColumn<ClearBoxTipOutData, String> getGsehDate() {
        return this.gsehDate;
    }

    public TableColumn<ClearBoxTipOutData, String> getGschVoucherId() {
        return this.gschVoucherId;
    }

    public TableColumn<ClearBoxTipOutData, String> getGschExaVoucherId() {
        return this.gschExaVoucherId;
    }

    public TableView<ClearBoxTipOutData> getTableView() {
        return this.tableView;
    }

    public TableColumn<ClearBoxTipOutData, CheckBox> getCheckBox() {
        return this.checkBox;
    }

    public TableColumn<ClearBoxTipOutData, String> getGsehType() {
        return this.gsehType;
    }

    public AnchorPane getPane() {
        return this.pane;
    }

    public AddBoxController getAddBoxController() {
        return this.addBoxController;
    }

    public ObservableList<ClearBoxTipOutData> getObservableTableList() {
        return this.observableTableList;
    }

    public AddBoxInfoOutData getAddBoxInfoOutData() {
        return this.addBoxInfoOutData;
    }

    public void setGschDate(TableColumn<ClearBoxTipOutData, String> gschDate) {
        this.gschDate = gschDate;
    }

    public void setGsehDate(TableColumn<ClearBoxTipOutData, String> gsehDate) {
        this.gsehDate = gsehDate;
    }

    public void setGschVoucherId(TableColumn<ClearBoxTipOutData, String> gschVoucherId) {
        this.gschVoucherId = gschVoucherId;
    }

    public void setGschExaVoucherId(TableColumn<ClearBoxTipOutData, String> gschExaVoucherId) {
        this.gschExaVoucherId = gschExaVoucherId;
    }

    public void setTableView(TableView<ClearBoxTipOutData> tableView) {
        this.tableView = tableView;
    }

    public void setCheckBox(TableColumn<ClearBoxTipOutData, CheckBox> checkBox) {
        this.checkBox = checkBox;
    }

    public void setGsehType(TableColumn<ClearBoxTipOutData, String> gsehType) {
        this.gsehType = gsehType;
    }

    public void setPane(AnchorPane pane) {
        this.pane = pane;
    }

    public void setAddBoxController(AddBoxController addBoxController) {
        this.addBoxController = addBoxController;
    }

    public void setObservableTableList(ObservableList<ClearBoxTipOutData> observableTableList) {
        this.observableTableList = observableTableList;
    }

    public void setAddBoxInfoOutData(AddBoxInfoOutData addBoxInfoOutData) {
        this.addBoxInfoOutData = addBoxInfoOutData;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof ClearBoxTipController)) {
            return false;
        }
        ClearBoxTipController other = (ClearBoxTipController)o;
        if (!other.canEqual(this)) {
            return false;
        }
        TableColumn<ClearBoxTipOutData, String> this$gschDate = this.getGschDate();
        TableColumn<ClearBoxTipOutData, String> other$gschDate = other.getGschDate();
        if (this$gschDate == null ? other$gschDate != null : !this$gschDate.equals(other$gschDate)) {
            return false;
        }
        TableColumn<ClearBoxTipOutData, String> this$gsehDate = this.getGsehDate();
        TableColumn<ClearBoxTipOutData, String> other$gsehDate = other.getGsehDate();
        if (this$gsehDate == null ? other$gsehDate != null : !this$gsehDate.equals(other$gsehDate)) {
            return false;
        }
        TableColumn<ClearBoxTipOutData, String> this$gschVoucherId = this.getGschVoucherId();
        TableColumn<ClearBoxTipOutData, String> other$gschVoucherId = other.getGschVoucherId();
        if (this$gschVoucherId == null ? other$gschVoucherId != null : !this$gschVoucherId.equals(other$gschVoucherId)) {
            return false;
        }
        TableColumn<ClearBoxTipOutData, String> this$gschExaVoucherId = this.getGschExaVoucherId();
        TableColumn<ClearBoxTipOutData, String> other$gschExaVoucherId = other.getGschExaVoucherId();
        if (this$gschExaVoucherId == null ? other$gschExaVoucherId != null : !this$gschExaVoucherId.equals(other$gschExaVoucherId)) {
            return false;
        }
        TableView<ClearBoxTipOutData> this$tableView = this.getTableView();
        TableView<ClearBoxTipOutData> other$tableView = other.getTableView();
        if (this$tableView == null ? other$tableView != null : !this$tableView.equals(other$tableView)) {
            return false;
        }
        TableColumn<ClearBoxTipOutData, CheckBox> this$checkBox = this.getCheckBox();
        TableColumn<ClearBoxTipOutData, CheckBox> other$checkBox = other.getCheckBox();
        if (this$checkBox == null ? other$checkBox != null : !this$checkBox.equals(other$checkBox)) {
            return false;
        }
        TableColumn<ClearBoxTipOutData, String> this$gsehType = this.getGsehType();
        TableColumn<ClearBoxTipOutData, String> other$gsehType = other.getGsehType();
        if (this$gsehType == null ? other$gsehType != null : !this$gsehType.equals(other$gsehType)) {
            return false;
        }
        AnchorPane this$pane = this.getPane();
        AnchorPane other$pane = other.getPane();
        if (this$pane == null ? other$pane != null : !this$pane.equals(other$pane)) {
            return false;
        }
        AddBoxController this$addBoxController = this.getAddBoxController();
        AddBoxController other$addBoxController = other.getAddBoxController();
        if (this$addBoxController == null ? other$addBoxController != null : !(this$addBoxController).equals(other$addBoxController)) {
            return false;
        }
        ObservableList<ClearBoxTipOutData> this$observableTableList = this.getObservableTableList();
        ObservableList<ClearBoxTipOutData> other$observableTableList = other.getObservableTableList();
        if (this$observableTableList == null ? other$observableTableList != null : !this$observableTableList.equals(other$observableTableList)) {
            return false;
        }
        AddBoxInfoOutData this$addBoxInfoOutData = this.getAddBoxInfoOutData();
        AddBoxInfoOutData other$addBoxInfoOutData = other.getAddBoxInfoOutData();
        return !(this$addBoxInfoOutData == null ? other$addBoxInfoOutData != null : !(this$addBoxInfoOutData).equals(other$addBoxInfoOutData));
    }

    protected boolean canEqual(Object other) {
        return other instanceof ClearBoxTipController;
    }

    public int hashCode() {
        int PRIME = 59;
        int result = 1;
        TableColumn<ClearBoxTipOutData, String> $gschDate = this.getGschDate();
        result = result * 59 + ($gschDate == null ? 43 : $gschDate.hashCode());
        TableColumn<ClearBoxTipOutData, String> $gsehDate = this.getGsehDate();
        result = result * 59 + ($gsehDate == null ? 43 : $gsehDate.hashCode());
        TableColumn<ClearBoxTipOutData, String> $gschVoucherId = this.getGschVoucherId();
        result = result * 59 + ($gschVoucherId == null ? 43 : $gschVoucherId.hashCode());
        TableColumn<ClearBoxTipOutData, String> $gschExaVoucherId = this.getGschExaVoucherId();
        result = result * 59 + ($gschExaVoucherId == null ? 43 : $gschExaVoucherId.hashCode());
        TableView<ClearBoxTipOutData> $tableView = this.getTableView();
        result = result * 59 + ($tableView == null ? 43 : $tableView.hashCode());
        TableColumn<ClearBoxTipOutData, CheckBox> $checkBox = this.getCheckBox();
        result = result * 59 + ($checkBox == null ? 43 : $checkBox.hashCode());
        TableColumn<ClearBoxTipOutData, String> $gsehType = this.getGsehType();
        result = result * 59 + ($gsehType == null ? 43 : $gsehType.hashCode());
        AnchorPane $pane = this.getPane();
        result = result * 59 + ($pane == null ? 43 : $pane.hashCode());
        AddBoxController $addBoxController = this.getAddBoxController();
        result = result * 59 + ($addBoxController == null ? 43 : ($addBoxController).hashCode());
        ObservableList<ClearBoxTipOutData> $observableTableList = this.getObservableTableList();
        result = result * 59 + ($observableTableList == null ? 43 : $observableTableList.hashCode());
        AddBoxInfoOutData $addBoxInfoOutData = this.getAddBoxInfoOutData();
        result = result * 59 + ($addBoxInfoOutData == null ? 43 : ($addBoxInfoOutData).hashCode());
        return result;
    }

    public String toString() {
        return "ClearBoxTipController(gschDate=" + this.getGschDate() + ", gsehDate=" + this.getGsehDate() + ", gschVoucherId=" + this.getGschVoucherId() + ", gschExaVoucherId=" + this.getGschExaVoucherId() + ", tableView=" + this.getTableView() + ", checkBox=" + this.getCheckBox() + ", gsehType=" + this.getGsehType() + ", pane=" + this.getPane() + ", addBoxController=" + this.getAddBoxController() + ", observableTableList=" + this.getObservableTableList() + ", addBoxInfoOutData=" + this.getAddBoxInfoOutData() + ")";
    }
}

